<template>
	<view>
		<view class="tabWrap tjTab">
			<!-- <view class="tabWrapItem">
				<view class="tabItem"
					:class="[orderStaIndex === index ? 'active' : '']"
					v-for="(item,index) in orderStaArr"
					:key="index"
				>{{item.name}}<view class="lineView"></view></view>
			</view> -->
			<view class="tabWrapItem">
				<view class="tabItem sm"
					:class="[subIndex === index ? 'active' : '']"
					v-for="(item,index) in subList"
					:key="index"
					@tap="switchSubject(index,item)"
				>{{item.subjectName}}<view class="lineView" v-if="subList.length >= 3"></view></view>
			</view>
		</view>
		<view class="errList padd">
			<view class="listItem"
				v-for="(item,index) in errBookList"
				:key="index"
			>
				<view class="queTit">{{item.loreName}}</view>
				<view class="queBot spaceBet">
					<view class="errTime">错误次数:{{item.errorCount}}次</view>
					<view class="botBtn hasFlex">
						<view class="dzBtn btn" @tap="goFourStudy(item)">去学习</view>
					</view>
				</view>
			</view>
			<!-- <view class="listItem">
				<view class="queTit">下列方程式中,是医院二次方程的是()</view>
				<view class="queBot spaceBet">
					<view class="errTime">错误次数:6次</view>
					<view class="botBtn hasFlex">
						<view class="dzBtn btn">去学习</view>
					</view>
				</view>
			</view> -->
		</view>
	</view>
</template>

<script>
	import { getLoreErrNumTj,getSelfSubject } from '@/api/zhuxue.js'
	export default {
		data(){
			return{
				subList:[],
				subId:0,
				subIndex:0,
				errBookList:[],
				isHasDataFlag:null
			}
		},
		onLoad(){
			this.getSelfSubjectList();
		},
		onPullDownRefresh : function(){
			this.loadloreErrTj();
			uni.stopPullDownRefresh();
		},
		methods:{
			getSelfSubjectList(){
				let field = { account:uni.getStorageSync('token') };
				let contentStr = this.crypto.encrypt(JSON.stringify( field )); 
				getSelfSubject({content:contentStr}).then(res=>{
					let tmpRes = res.data.datas;
					this.subList = tmpRes.subjectList;
					this.subId = this.subList[0].subjectId;
					this.loadloreErrTj();
				}).catch(err=>{
					console.log(err)
				});
			},
			loadloreErrTj(){
				let field = { subId:this.subId,comTag:1,userId:uni.getStorageSync('userId') };
				console.log(field);
				getLoreErrNumTj(field).then(res=>{
					
					this.errBookList = res.data.datas;
					console.log(res);
				}).catch(err=>{});
			},
			switchSubject(index,item){
				this.subIndex = index;
				this.subId = item.subjectId;
				this.loadloreErrTj();
			},
			goFourStudy(item){
				uni.navigateTo({
					url:'/pages/subIndex/errBook/fourStep?loreId=' + item.loreId + '&loreName=' + item.loreName
				})
			}
		}
	}
</script>
<style>
	page{
		background: #f9f8f6;
	}
</style>
<style lang="scss" scoped>
	@import '@/static/scss/errBookList.scss';
</style>